<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
    </script>
</head>
<body>
<div class="container">
    <form>
        <div class="form-group">
            <label>用户名</label>
            <input type="text" name="username" class="form-control">
        </div>
        <div class="form-group">
            <label for="exampleInputPassword1">密码</label>
            <input type="password" name="password" class="form-control" id="exampleInputPassword1">
        </div>
        <button type="button" class="btn btn-primary sub">Submit</button>
    </form>
</div>
</body>
</html>
<script>
    $(".sub").on('click',function () {
        var username = $("input[name=username]").val()
        var password = $("input[name=password]").val()
            $.ajax({
                url:"{:url('admin/user/dologin')}",
                data:{username:username,password:password},
                type: "post",
                success(res) {
                    alert(res.msg)
                    if (res.code == 300){
                        window.location.href="{:url('admin/goods/index')}"
                    }
                }
            })
    })
</script>